<!-- 销售开单报表 -->
<template>
  <view>
    <hx-navbar ref="hxnb" :config="config" @clickBtn="clickBtn"></hx-navbar>
    <view v-for="(item, index) in data" :key="index">
      <view class="list-view" @click="selectItem(item,index)">
        <view class="item">
          <u-icon name="chat" color="#2979ff" size="18"></u-icon>
          <view class="con">{{item.name}}</view>
          <u-icon name="photo" color="#2979ff" size="18"></u-icon>
        </view>
      </view>
    </view>

    <!-- 打印设置 -->
    <u-popup
      class="u-pop"
      :show="show"
      :round="6"
      mode="center"
      :closeOnClickOverlay="false"
    >
      <view class="popup-view">
        <view class="title p-b-10"> 本地报表打印设置 </view>
        <view class="cell-item">
          <view class="label">列数</view>
          <view class="value-view flex">
            <u--input border="surround"></u--input>
          </view>
        </view>
        <view class="cell-item">
          <view class="label">明细</view>
          <view class="value-view flex">
            <u--input border="surround" disabled></u--input>
          </view>
        </view>
        <view class="cell-item">
          <view class="label">汇总</view>
          <view class="value-view flex">
            <u--input border="surround" disabled></u--input>
          </view>
        </view>
        <view class="cell-item">
          <view class="label">合计</view>
          <view class="value-view flex">
            <u--input border="surround" disabled></u--input>
          </view>
        </view>
        <view class="bot-view flex flex-sa">
          <view
            class="btn"
            @click="
              () => {
                show = false;
              }
            "
          >
            取消
          </view>
          <view class="btn" @click="onSaveCancel(true)"> 保存 </view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import { getListOptionsByTypeId } from "@/apis/bill/print";
export default {
  name: "SalesReport",
  data() {
    return {
      config: {
        title: "销售开单报表",
        color: "#ffffff",
        //背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
        backgroundColor: [1, ["#409EFF", "#409EFF", "#60b4f6", "#60b4f6"]],
        // backTabPage: '/pages/application/index'
        backTabPage: "",
        backPage: "",
        // rightButton: [
        //   {
        //     key: "btn1",
        //     icon: "&#xe727;",
        //     position: "left",
        //   },
        // ],
      },
      show: false,
      data: [],
    };
  },
  onLoad(e) {
    if (e.type) {
      this.getListOptionsByTypeId(e.type);
    }
  },
  methods: {
		selectItem(item,index){
			uni.$emit("on-sales-report",item)
			setTimeout(()=>{
				uni.navigateBack()
			},100)
		},
    getListOptionsByTypeId(type) {
      getListOptionsByTypeId(type).then((res) => {
        if (!res.flag) return;
        this.data = res.data || [];
        console.log("this.data", this.data);
        // this.getVoByIds(data[0].id);
      });
    },

    clickBtn(item) {
      if (item.key === "btn1") {
        this.show = true;
      }
    },
    onSaveCancel(show) {
      this.show = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.list-view {
  .item {
    display: flex;
    justify-content: space-between;
    background: #fff;
    padding: 40rpx 20rpx;
    border-bottom: 1rpx solid #efefef;
    .con {
      flex: 1;
      padding: 0 20rpx;
      font-size: 30rpx;
    }
  }
}
.cell-item {
  display: flex;
  height: 80rpx;
  align-items: center;
  font-size: 30rpx;
  margin-bottom: 26rpx;
  .label {
    width: 100rpx;
    text-align: right;
    color: #333;
  }
  .value-view {
    padding-left: 30rpx;
    padding-right: 60rpx;
    flex: 1;
    justify-content: space-between;
  }
}
</style>